#ifndef IGAMEPLAY_H
#define IGAMEPLAY_H


#include <d3d9.h>
#include <d3dx9.h>

#include "Timer.h"
#include "CStateManager.h"

class CStateManager;

#define SCREEN_WIDTH	800
#define SCREEN_HEIGHT	600
#define	FRAME_RATE		60


class IGamePlay
{
public:

	///---------------------------------------------------------------------------------------
	// Constructor & Destructor for this class -----------------------------------------------
	///---------------------------------------------------------------------------------------
			 IGamePlay(void);
	virtual ~IGamePlay(void);

	//-----------------------------------------------------------------------------------------
	/// Public function------------------------------------------------------------------------
	//-----------------------------------------------------------------------------------------
	static LRESULT CALLBACK		StaticWinProc(HWND, UINT, WPARAM, LPARAM);
	BOOL						GameInit(HINSTANCE);
	void						GameRun();
	void						GameEnd();
	LPDIRECT3DDEVICE9			GetDevice();

	virtual void	Init() {};
	virtual void	Update() {};
	virtual void	Render() {};
	virtual void	Destroy() {};

	CStateManager	*m_pStateManager;

private:

	//-----------------------------------------------------------------------------------------
	/// Private Variables ---------------------------------------------------------------------
	//-----------------------------------------------------------------------------------------

	HWND						m_hWnd;

	Timer						m_Timer;

	BOOL						m_bLostDevice;
	BOOL						m_bActiveRender;
	BOOL						m_bActiveKey;

	USHORT						m_usLastFrameRate;
	USHORT						m_usFrameRate;

	D3DXMATRIX					m_mtxView;
	D3DXMATRIX					m_mtxProjection;

	LPDIRECT3D9					m_pD3D;
	LPDIRECT3DDEVICE9			m_pD3DDevice;
	D3DPRESENT_PARAMETERS		m_D3DPresentParam;

	//-----------------------------------------------------------------------------------------
	/// Private Function ----------------------------------------------------------------------
	//-----------------------------------------------------------------------------------------

	BOOL						InitWindow(HINSTANCE);
	BOOL						InitDirect3D();

	void						FrameAdvance();
	void						RenderGame();
	void						UpdateGame();
	LRESULT CALLBACK			WinProc(HWND, UINT, WPARAM, LPARAM);
};	


#endif